Skip to content

Conversation

@n8han
Copy link
Collaborator

@n8han n8han commented Nov 2, 2021

This continues the work of PR #615 and closes #261, closes #540, and replaces
the changed calculation of #681 with a more general solution.

The underlying issue here is that the attribution button is left-aligned
by default on Android, and right-aligned by default on iOS. The approach
taken in #681 where the margin x value is assumed to represent the left
margin does not generalize to iOS, where it will be a right margin.

Since the alignment / gravity of the button can be configured on each
platform, we can address this problem at its source by exposing this
configuration through flutter-mapbox-gl. Then on Android, we can apply
the button margins same way the compass is positioned, with respect to
its gravity.

I've tested this on iOS and Android with both bottom left and bottom
right attribution buttons. The best option currently is to configure the
attribution button to bottom right, where it falls by default on iOS. In
this way you will have a similar experience on both platforms with a
fully configurable margin.

The mapbox logo's alignment/position is also configurable, should anyone
want to expose it in future.

chingyawhao and others added 5 commits April 18, 2021 21:42
This continues the work of PR #615 to fix #261 and #540, and replaces
the changed calculation of #681 with a more general solution.

The underlying issue here is that the attribution button is left-aligned
by default on Android, and right-aligned by default on iOS. The approach
taken in #681 where the margin x value is assumed to represent the left
margin does not generalize to iOS, where it will be a right margin.

Since the alignment / gravity of the button can be configured on each
platform, we can address this problem at its source by exposing this
configuration through flutter-mapbox-gl. Then on Android, we can apply
the button margins same way the compass is positioned, with respect to
its gravity.

I've tested this on iOS and Android with both bottom left and bottom
right attribution buttons. The best option currently is to configure the
attribution button to bottom right, where it falls by default on iOS. In
this way you will have a similar experience on both platforms with a
fully configurable margin.

The mapbox logo's alignment/position is also configurable, should anyone
want to expose it in future.
@n8han n8han had a problem deploying to ANDROID_CI_DOWNLOADS_TOKEN November 2, 2021 02:04 Failure
@n8han n8han had a problem deploying to ANDROID_CI_DOWNLOADS_TOKEN November 2, 2021 02:04 Failure
@n8han n8han requested a review from felix-ht November 2, 2021 02:04
n8han added 2 commits November 2, 2021 21:09
When setting the position of the compass and attribution button, we need
to assume the platform default gravity for those elements if no explicit
value has been provided. An incorrect default was assumed for the
attribution button (copied from the compass), so that is corrected here.

The methods for setting gravity do not require a default since they are
only called if an explicit gravity value has been provided. Those
default cases are removed here.

#731 (comment)
This name is not commonly used outside of android. Also, we're
converting to the typed position objects as quickly as possible with
these changes, rather than passing around the int.

#731 (comment)
@n8han n8han had a problem deploying to ANDROID_CI_DOWNLOADS_TOKEN November 3, 2021 01:13 Failure
@n8han n8han had a problem deploying to ANDROID_CI_DOWNLOADS_TOKEN November 3, 2021 01:13 Failure
Copy link
Collaborator

@felix-ht felix-ht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@felix-ht felix-ht merged commit 9a54c9d into master Nov 4, 2021
n8han added a commit that referenced this pull request Nov 8, 2021
When setting the position of the compass and attribution button, we need
to assume the platform default gravity for those elements if no explicit
value has been provided. An incorrect default was assumed for the
attribution button (copied from the compass), so that is corrected here.

The methods for setting gravity do not require a default since they are
only called if an explicit gravity value has been provided. Those
default cases are removed here.

#731 (comment)
n8han added a commit that referenced this pull request Nov 8, 2021
This name is not commonly used outside of android. Also, we're
converting to the typed position objects as quickly as possible with
these changes, rather than passing around the int.

#731 (comment)
@n8han n8han deleted the AndroidOverlayButtonFixes branch November 8, 2021 13:14
@n8han n8han restored the AndroidOverlayButtonFixes branch November 8, 2021 13:15
@n8han n8han deleted the AndroidOverlayButtonFixes branch November 8, 2021 13:15
@felix-ht felix-ht mentioned this pull request Nov 12, 2021
m0nac0 pushed a commit to maplibre/flutter-maplibre-gl that referenced this pull request Nov 19, 2021
* fix(android): allow android logoViewMargins and attributionButtonMargins to behave similarly to ios

* fix(convert): compass view margin remain the same since theres the gravity and it cant be tested now

* feat(setAttributionButtonMargins): adding variable name to the constant and adjust it to density

* Add attribution button gravity, position normally

This continues the work of PR #615 to fix #261 and #540, and replaces
the changed calculation of #681 with a more general solution.

The underlying issue here is that the attribution button is left-aligned
by default on Android, and right-aligned by default on iOS. The approach
taken in #681 where the margin x value is assumed to represent the left
margin does not generalize to iOS, where it will be a right margin.

Since the alignment / gravity of the button can be configured on each
platform, we can address this problem at its source by exposing this
configuration through flutter-mapbox-gl. Then on Android, we can apply
the button margins same way the compass is positioned, with respect to
its gravity.

I've tested this on iOS and Android with both bottom left and bottom
right attribution buttons. The best option currently is to configure the
attribution button to bottom right, where it falls by default on iOS. In
this way you will have a similar experience on both platforms with a
fully configurable margin.

The mapbox logo's alignment/position is also configurable, should anyone
want to expose it in future.

* Improve switch default behavior

When setting the position of the compass and attribution button, we need
to assume the platform default gravity for those elements if no explicit
value has been provided. An incorrect default was assumed for the
attribution button (copied from the compass), so that is corrected here.

The methods for setting gravity do not require a default since they are
only called if an explicit gravity value has been provided. Those
default cases are removed here.

flutter-mapbox-gl/maps#731 (comment)

* Rename "gravity" methods in web implementation

This name is not commonly used outside of android. Also, we're
converting to the typed position objects as quickly as possible with
these changes, rather than passing around the int.

flutter-mapbox-gl/maps#731 (comment)

Co-authored-by: Ching Yaw Hao <[email protected]>
(cherry picked from commit 9a54c9d2c0e2fc8b27e8035bacdb5710fd0e2767)
m0nac0 added a commit to maplibre/flutter-maplibre-gl that referenced this pull request Nov 19, 2021
…eam#731) (#50)

* Add attribution button gravity, position normally  (#731)

* fix(android): allow android logoViewMargins and attributionButtonMargins to behave similarly to ios

* fix(convert): compass view margin remain the same since theres the gravity and it cant be tested now

* feat(setAttributionButtonMargins): adding variable name to the constant and adjust it to density

* Add attribution button gravity, position normally

This continues the work of PR #615 to fix #261 and #540, and replaces
the changed calculation of #681 with a more general solution.

The underlying issue here is that the attribution button is left-aligned
by default on Android, and right-aligned by default on iOS. The approach
taken in #681 where the margin x value is assumed to represent the left
margin does not generalize to iOS, where it will be a right margin.

Since the alignment / gravity of the button can be configured on each
platform, we can address this problem at its source by exposing this
configuration through flutter-mapbox-gl. Then on Android, we can apply
the button margins same way the compass is positioned, with respect to
its gravity.

I've tested this on iOS and Android with both bottom left and bottom
right attribution buttons. The best option currently is to configure the
attribution button to bottom right, where it falls by default on iOS. In
this way you will have a similar experience on both platforms with a
fully configurable margin.

The mapbox logo's alignment/position is also configurable, should anyone
want to expose it in future.

* Improve switch default behavior

When setting the position of the compass and attribution button, we need
to assume the platform default gravity for those elements if no explicit
value has been provided. An incorrect default was assumed for the
attribution button (copied from the compass), so that is corrected here.

The methods for setting gravity do not require a default since they are
only called if an explicit gravity value has been provided. Those
default cases are removed here.

flutter-mapbox-gl/maps#731 (comment)

* Rename "gravity" methods in web implementation

This name is not commonly used outside of android. Also, we're
converting to the typed position objects as quickly as possible with
these changes, rather than passing around the int.

flutter-mapbox-gl/maps#731 (comment)

Co-authored-by: Ching Yaw Hao <[email protected]>
(cherry picked from commit 9a54c9d2c0e2fc8b27e8035bacdb5710fd0e2767)

* Fix formatting

Co-authored-by: Nathan <[email protected]>
github-actions bot pushed a commit to maplibre/flutter-maplibre-gl that referenced this pull request Nov 19, 2021
…(upstream#731) (#50)

* Add attribution button gravity, position normally  (#731)

* fix(android): allow android logoViewMargins and attributionButtonMargins to behave similarly to ios

* fix(convert): compass view margin remain the same since theres the gravity and it cant be tested now

* feat(setAttributionButtonMargins): adding variable name to the constant and adjust it to density

* Add attribution button gravity, position normally

This continues the work of PR #615 to fix #261 and #540, and replaces
the changed calculation of #681 with a more general solution.

The underlying issue here is that the attribution button is left-aligned
by default on Android, and right-aligned by default on iOS. The approach
taken in #681 where the margin x value is assumed to represent the left
margin does not generalize to iOS, where it will be a right margin.

Since the alignment / gravity of the button can be configured on each
platform, we can address this problem at its source by exposing this
configuration through flutter-mapbox-gl. Then on Android, we can apply
the button margins same way the compass is positioned, with respect to
its gravity.

I've tested this on iOS and Android with both bottom left and bottom
right attribution buttons. The best option currently is to configure the
attribution button to bottom right, where it falls by default on iOS. In
this way you will have a similar experience on both platforms with a
fully configurable margin.

The mapbox logo's alignment/position is also configurable, should anyone
want to expose it in future.

* Improve switch default behavior

When setting the position of the compass and attribution button, we need
to assume the platform default gravity for those elements if no explicit
value has been provided. An incorrect default was assumed for the
attribution button (copied from the compass), so that is corrected here.

The methods for setting gravity do not require a default since they are
only called if an explicit gravity value has been provided. Those
default cases are removed here.

flutter-mapbox-gl/maps#731 (comment)

* Rename gravity methods in web implementation

This name is not commonly used outside of android. Also, we're
converting to the typed position objects as quickly as possible with
these changes, rather than passing around the int.

flutter-mapbox-gl/maps#731 (comment)

Co-authored-by: Ching Yaw Hao <[email protected]>
(cherry picked from commit 9a54c9d2c0e2fc8b27e8035bacdb5710fd0e2767)

* Fix formatting

Co-authored-by: Nathan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

attributionButtonMargins not working as expected Android - Compass View Margin Issue

4 participants